package controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import dao.EmpDao;
import entity.Emp;
import utils.R;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "DelServlet",urlPatterns = "/toDel")
public class DelServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ids = request.getParameter("id");
        Integer id = Integer.parseInt(ids);
        System.out.println("id="+id);
        EmpDao empDao = new EmpDao();
        Integer row = empDao.delById(id);

        if(row==1){
            response.sendRedirect(request.getContextPath()+"/emplist");
        }


    }
}
